const mongoose = require("mongoose")
const { getNowTime } = require("../utils/tools")

const MenuType = new mongoose.Schema({
    parentid: { type: String, required: true },
    type: { type: String, default: "directory", required: true },
    name: { type: String, required: true }, // 名称
    icon: String,
    sort: Number,
    status: { type: Boolean, default: true }, //显示状态
    component: String,
    path: String,
    link: { type: Boolean, default: false, },
    cache: { type: Boolean, default: false, required: true },
    createTiem: {
        type: String,
        set() {
            return getNowTime()
        },
        default: getNowTime(),
        required: true,
    },
})


const schema = mongoose.Schema(MenuType)

const MenuModel = mongoose.model("menu", schema)

module.exports = MenuModel